package cn.iocoder.yudao.module.bpm.dal.mysql.tohandle;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.tohandle.collect.vo.BpmHandleCollectExportReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.tohandle.collect.vo.BpmHandleCollectPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.tohandle.BpmHandleCollectDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 审批流——我的收藏 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface BpmHandleCollectMapper extends BaseMapperX<BpmHandleCollectDO> {

    default PageResult<BpmHandleCollectDO> selectPage(BpmHandleCollectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmHandleCollectDO>()
                .eqIfPresent(BpmHandleCollectDO::getBpmHandleFlowId, reqVO.getBpmHandleFlowId())
                .eqIfPresent(BpmHandleCollectDO::getBpmHandleTaskId, reqVO.getBpmHandleTaskId())
                .likeIfPresent(BpmHandleCollectDO::getUsername, reqVO.getUsername())
                .likeIfPresent(BpmHandleCollectDO::getCreator, reqVO.getCreator())
                .likeIfPresent(BpmHandleCollectDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(BpmHandleCollectDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BpmHandleCollectDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(BpmHandleCollectDO::getDeleted, reqVO.getDeleted())
                .orderByDesc(BpmHandleCollectDO::getId));
    }

    default List<BpmHandleCollectDO> selectList(BpmHandleCollectExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<BpmHandleCollectDO>()
                .eqIfPresent(BpmHandleCollectDO::getBpmHandleFlowId, reqVO.getBpmHandleFlowId())
                .eqIfPresent(BpmHandleCollectDO::getBpmHandleTaskId, reqVO.getBpmHandleTaskId())
                .likeIfPresent(BpmHandleCollectDO::getUsername, reqVO.getUsername())
                .likeIfPresent(BpmHandleCollectDO::getCreator, reqVO.getCreator())
                .likeIfPresent(BpmHandleCollectDO::getUpdater, reqVO.getUpdater())
                .betweenIfPresent(BpmHandleCollectDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(BpmHandleCollectDO::getUpdateTime, reqVO.getUpdateTime())
                .eqIfPresent(BpmHandleCollectDO::getDeleted, reqVO.getDeleted())
                .orderByDesc(BpmHandleCollectDO::getId));
    }

}
